// pages/shop-account/signing/progress.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    done1: "yes",
    done2: "none",
    done3: "none",
    sec: 20,
    cur: 20,
    transformRight: "",
    transformLeft: "",
    bgColorRight: "#e93324",
    bgColorLeft: "#e93324",
    step: "step1"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let that = this;
    setTimeout(function() {
      that.onTimeOut()
    }, 1000)
  },

  onTimeOut() {
    let that = this;
    let cur = that.data.cur - 1
    that.setData({
      cur: cur
    })
    let sec = that.data.sec;
    let percent = (1 - cur / sec) * 100
    if (percent <= 50) {
      that.setData({
        transformRight: "transform:rotate(" + (percent * 3.6) + "deg)"
      })
    } else {
      if (percent == 100) {
        that.setData({
          transformRight: "transform:rotate(0deg)",
          bgColorRight: "#f2f2f2",
          transformLeft: "transform:rotate:(0deg)",
          bgColorLeft: "#f2f2f2",
        })
      } else {
        that.setData({
          transformRight: "transform:rotate(0deg)",
          bgColorRight: "#f2f2f2",
          transformLeft: "transform:rotate(" + ((percent - 50) * 3.6) + "deg)"
        })
      }
    }
    if (cur > 0) {
      setTimeout(function() {
        that.onTimeOut()
      }, 1000)
    } else {
      that.setData({
        step: "step2",
        done2: "yes",
        done3: "yes"
      })
    }
  },
  succ() {
    let that = this;
    that.setData({
      step: "step3",
      done2: "yes",
      done3: "no"
    })
  },
  fail() {
    let that = this;
    that.setData({
      step: "step4",
      done2: "none",
      done3: "none"
    })
  },
  done() {
    let that = this;
    that.setData({
      step: "step5",
      done2: "yes",
      done3: "none"
    })
  },
  help() {
    tt.navigateTo({
      url: './help',
    })
  },
  wait() {
    tt.redirectTo({
      url: './done',
    })
  }
})